/**********************************************************
 * MailServerDelegator.java.java 
 * Created by Ashutosh
 * Last modified Date: Sep 18, 2008 10:55:34 AM by Ashutosh
 * Revision: <svn revision #> 
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.delegator;

import static com.printeverywhere.util.AttributeConstants.CLOSING_SESSION;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.printeverywhere.dto.MailServer;
import com.printeverywhere.util.HibernateUtil;

/**
 * The Class MailServerDelegator.
 */
public class MailServerDelegator {
	
	/** The log. */
	private static Logger log = Logger.getLogger(UserServiceDelegator.class);
	
	/**
	 * Gets the mail details.
	 * 
	 * @param userId the user id
	 * 
	 * @return the mail details
	 */
	public static List<MailServer> getMailDetails(String userId) {
		Session session  = HibernateUtil.getSession();
		try {			
			Transaction tc = session.beginTransaction();
			List<MailServer> list = session.createCriteria(MailServer.class).list();
			tc.commit();
			return list;
		} catch (HibernateException e) {
			log.error("Got exception when getting list for NumberFormat without search criteria".intern());
			throw e;
		} finally {
			if(log.isInfoEnabled()){
				log.info(CLOSING_SESSION);
			}
			session.flush();
			session.close();
		}		
	}

	/**
	 * Gets the outbox mail.
	 * 
	 * @param userId the user id
	 * 
	 * @return the outbox mail
	 */
	public static List<MailServer> getOutboxMail(String userId) {
		Session session  = HibernateUtil.getSession();
		try {
			
		} catch (Exception e) {
			// TODO: handle exception
		}
		return null;	
	}
}